﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SqlAntlr
{
    public class Pair<T, S>
    {
        //public class Pair<T,S> implements Comparable{
        public T x { get; private set; }
        public S y { get; private set; }

        public Pair(T x, S y)
        {
            this.x = x;
            this.y = y;
        }

        public override bool Equals(Object o)
        {
            if (o is Pair<T, S>)
            {
                Pair<T, S> p = (Pair<T, S>)o;
                return x.Equals(p.x) && y.Equals(p.y);
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() * 33 + y.GetHashCode();
        }

        public int compareTo(Object o)
        {
            if (o is Pair<T, S>)
            {
                if (x is IComparable)
                {
                    return ((IComparable)x).CompareTo(((Pair<T, S>)o).x);
                }
            }
            return -1;
        }
    }
}
